<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>用户注册页面</title>
		<link rel="stylesheet" type="text/css" href="css/register1.css" />
	</head>
<%--	<script>function oncheck() {--%>
<%--		var userId = document.getElementById("user").value;--%>
<%--		var passId = document.getElementById("pass").value;--%>
<%--		var passId1 = document.getElementById("pass1").value;--%>
<%--		if(userId.replace(/^ +| +$/g, '') == '' || passId.replace(/^ +| +$/g, '') == '') {--%>
<%--			alert("账号或密码不能为空");--%>

<%--		} else if(userId.replace(/[^0-9]/g, '') && passId.replace(/[^0-9a-zA-Z]/g, '') && passId.length >= 6 && passId.length <= 32) {--%>
<%--			if(passId != passId1){--%>
<%--				alert("密码不一致");--%>
<%--			}--%>

<%--		}--%>

<%--		else {--%>
<%--			alert("账号或密码错误");--%>
<%--		}--%>
<%--	}</script>--%>
	<body>
		<div id="register">
			<div id="register_left">
				<img src="img/cc27dbf0927f9af0ed4c0d0fdfb3861.png" />
			</div>
			<div id="register_content">
				<form action="registerSubmit.jsp" method="post" id="form1">
					<div id="register_content_input">
						<label><strong>*通过用户名快速注册</strong></label>
						<input type="text" name="name" placeholder="请输入用户名" id="user" maxlength="10"/>
					</div>
					<div id="register_content_input">
						<label><strong>密码：</strong></label>
						<input type="password" name="password" value="" maxlength="32" id="pass" />
						<label><strong>*密码需由6-32个字符组成，只允许数字、字母，区分大小写。</strong></label>
					</div>
					<div id="register_content_input">
						<label><strong>确认密码：</strong></label>
						<input type="text" name="refill" value=""  id="pass1"/>
					</div>
					<%
							if(request.getParameter("err")!=null){
								String Err = request.getParameter("err");
								switch(Err){
									case "1": out.print("<span >用户名已存在</span>");break;
									case "2": out.print("<span>密码不一致</span>");break;
									case "3": out.print("<span>注册成功</span>");break;
								}
							}
					%>
					<div id="register_footer">
						<input type="submit"  id="" value="快速注册"  onmousedown="oncheck()"/>
						<input type="button"  value="返回"  onclick="window.location.href='Login.jsp'" />

						<div id="register_footer_content">
							点击“立即注册”，即表示您同意并愿意遵守邂逅书屋
							<a href="#">在线实名注册使用协议</a>
						</div>
					</div>
				</form>
			</div>			
		</div>
	</body>
	<script>
		function oncheck() {
			var userId = document.getElementById("user").value;
			var passId = document.getElementById("pass").value;
			var passId1 = document.getElementById("pass1").value;
			if(userId.replace(/^ +| +$/g, '') == '' || passId.replace(/^ +| +$/g, '') == '') {
				alert("账号或密码不能为空");

			} else if(userId.replace(/[^\u4E00-\u9FA5\A-\Z\a-\z]/g,'')) {
				if(passId.replace(/[^0-9a-zA-Z]/g, '') && passId.length>=6){
					if(passId == passId1){
						alert("注册成功");
						document.getElementById("form1").submit();
					}
					else alert("密码不一致");
				}

				else alert("密码过长或过短");
			}

			else {
				alert("您的用户名含非法字符，请重新输入");
			}
		}</script>
</html>